package com.woniu.petkonwledge.mapper;

import com.woniu.common.entity.Study;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface StudyMapper {
    @Insert("insert into study(myoption,qb_id,u_id) values(#{myoption},#{questionBank.id},#{user.id})")
    public void insertStudy(Study study);
    @Select("select * from study where u_id=#{u_id}")
    @Results({
            @Result(id = true,column = "id",property = "id"),
            @Result(column = "myoption",property = "myoption"),
            @Result(column = "qb_id",property = "questionBank",
            many = @Many(select ="com.woniu.petkonwledge.mapper.QuestionBankMapper.getQuestionById")),
            @Result(column = "u_id",property = "user.id")
    })
    public List<Study> getStudyByU_id(int u_id);
}
